package com.example.testsinglety.order;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/orders")
public class OrderController {
    @Autowired
    private OrderProducer orderProducer;

    @PostMapping("/test1")
    public String createOrder() {
        String orderId = "ORD_" + System.currentTimeMillis();
        // 核心解耦点：不直接调用库存服务
        orderProducer.sendOrderCreatedEvent(orderId);
        return "Order created: " + orderId;
    }

}
